package cn.wolfcode.crm.service.imp;

import cn.wolfcode.crm.domain.Education;
import cn.wolfcode.crm.mapper.EducationMapper;
import cn.wolfcode.crm.qo.PageResult;
import cn.wolfcode.crm.qo.QueryObject;
import cn.wolfcode.crm.service.IEducationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class EducationServiceImpl implements IEducationService {

    @Autowired
    private EducationMapper educationMapper;
    @Override
    public void saveOrUpdate(Education entity) {
        if (entity.getId() != null) {
            //更新操作
            educationMapper.updateByPrimaryKey(entity);


        }else {

            educationMapper.insert(entity);
        }

    }

    @Override
    public int delete(Long id) {
        return educationMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Education> selectAll() {
        return educationMapper.selectAll();
    }

    @Override
    public PageResult queryForList(QueryObject qo) {
        int rows = educationMapper.rows(qo);
        if (rows==0) {
            return PageResult.EMPTY_RESULT;
        }
        PageResult result =  new PageResult(rows,educationMapper.queryForList(qo));
        return result;
    }
}
